import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 排课信息 */
export interface ClassSetting {
  id?: number; // 排课表id（改为可选）
  classesId: number; // 班级关联id
  venueId?: number | null; // 场地关联id（添加为可选 null）
  sequence: string; // 上课顺序
  weekly: string; // 周次
  weekNumber: string; // 周序（添加）
}

// 排课 API
export const ClassSettingApi = {
  // 查询排课记录
  getClassSettingList: async (params: any) => {
    return await request.get({ url: `/train/class-setting/list`, params })
  },

  // 查询排课详情
  getClassSetting: async (id: number) => {
    return await request.get({ url: `/train/class-setting/get?id=` + id })
  },

  // 新增排课
  createClassSetting: async (data: ClassSetting) => {
    return await request.post({ url: `/train/class-setting/create`, data })
  },

  // 修改排课
  updateClassSetting: async (data: ClassSetting) => {
    return await request.put({ url: `/train/class-setting/update`, data })
  },

  // 删除排课
  deleteClassSetting: async (id: number) => {
    return await request.delete({ url: `/train/class-setting/delete?id=` + id })
  },

  /** 批量删除排课 */
  deleteClassSettingList: async (ids: number[]) => {
    return await request.delete({ url: `/train/class-setting/delete-list?ids=${ids.join(',')}` })
  },

  // 导出排课 Excel
  exportClassSetting: async (params) => {
    return await request.download({ url: `/train/class-setting/export-excel`, params })
  }
}
